﻿@model CameraModel
@using Nop.Web.Models.WindAlert;
@using Nop.Core
@using Nop.Core.Domain.Seo;
@using Nop.Core.Infrastructure;
@using Nop.Services.Localization

@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";
    Html.AddTitleParts(!String.IsNullOrEmpty(Model.MetaTitle) ? Model.MetaTitle : Model.Name);
    Html.AddMetaDescriptionParts(Model.MetaDescription);
    Html.AddMetaKeywordParts(Model.MetaKeywords);

    var canonicalUrlsEnabled = EngineContext.Current.Resolve<SeoSettings>().CanonicalUrlsEnabled;
    if (canonicalUrlsEnabled)
    {
        var storeUrl = Url.RouteUrl("Camera", new { SeName = Model.SeName }, this.Request.Url.Scheme);
        Html.AddCanonicalUrlParts(storeUrl);
    }
    Random random = new Random();
    Html.AddScriptParts("~/Windalert/scripts/Nivo/jquery.nivo.slider.js");
    Html.AddCssFileParts("~/Windalert/scripts/nivo/nivo-slider.css");
    Html.AddCssFileParts("~/Windalert/scripts/nivo/themes/default/default.css");

    bool IsRegistered = (bool)ViewData["IsRegistered"];

    var seoSettings = EngineContext.Current.Resolve<SeoSettings>();
    //open graph META tags
    if (seoSettings.OpenGraphMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"og:type\" content=\"product\" />");
        Html.AddHeadCustomParts("<meta property=\"og:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:image\" content=\"" + Model.CameraLink + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
        Html.AddHeadCustomParts("<meta property=\"og:site_name\" content=\"" + Html.Encode(storeName) + "\" />");
    }

    //Twitter META tags
    if (seoSettings.TwitterMetaTags)
    {
        var storeName = EngineContext.Current.Resolve<IStoreContext>().CurrentStore.GetLocalized(x => x.Name);
        Html.AddHeadCustomParts("<meta property=\"twitter:card\" content=\"summary\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:site\" content=\"" + Html.Encode(storeName) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:title\" content=\"" + Html.Encode(Model.Name) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:description\" content=\"" + Html.Encode(Model.MetaDescription) + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:image\" content=\"" + Model.CameraLink + "\" />");
        Html.AddHeadCustomParts("<meta property=\"twitter:url\" content=\"" + Request.Url.AbsoluteUri + "\" />");
    }
}

<script type="text/javascript">
    $(window).load(function () {
        $('#nivo-slider-camera-page').nivoSlider(
            {
                effect: 'none', pauseOnHover: false,
                animSpeed: 500, // Slide transition speed
                pauseTime: 500
            });
    });
</script>
@Html.Widget("windalert_camera_page_before_camera")
<div class="panel panel-default form-panel">
    <div class="panel-heading">
        <h3 class="">@T("Windalert.Cameras.Camera") - @Model.Name</h3>
    </div>
    <div class="panel-body">
        <div class="row">
            <div class="col-md-12" style="margin-bottom:10px;">
                    <!-- AddThis Button BEGIN --><div class="addthis_toolbox addthis_default_style ">
                        <a class="addthis_button_preferred_1"></a>
                        <a class="addthis_button_preferred_2"></a>
                        <a class="addthis_button_preferred_3">
                        </a><a class="addthis_button_preferred_4"></a>
                        <a class="addthis_button_compact"></a>
                        <a class="addthis_counter addthis_bubble_style"></a>
                    </div>
                    <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=nopsolutions"></script><!-- AddThis Button END -->
            </div>
        </div>
        <div class="row">
            <div class="col-md-12">
                @if (!string.IsNullOrEmpty(Model.SponserName))
                {
                    <span>@T("Windalert.Cameras.CameraSponser"): </span>
                    if (string.IsNullOrEmpty(Model.SponserLink))
                    {
                        @Model.SponserName
                    }
                    else
                    {
                        <a href="@Model.SponserLink" target="_blank">@Model.SponserName</a>
                    }
                }
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 text-center">
                <div class="slider-wrapper theme-default">
                    <div id="nivo-slider-camera-page" class="nivoSlider">
                        @for (int i = 0; i < 10; i++)
                        {
                            <img src="@(Model.CameraLink + i + ".jpg?" +  random.Next(1000, 9000).ToString())" data-thumb="" data-transition="" alt="" title="" />
                        }
                    </div>
                </div>
            </div>
        </div>
        @Html.Widget("windalert_camera_page_after_camera")
        <div class="row">
            <div class="col-md-12">
                @Html.Raw(Model.Description)

            </div>
        </div>

    </div>
</div>


@if (!IsRegistered)
{
    @Html.Action("Login", "WCustomer");
    <script type="text/javascript">
        $(window).load(function () {
            $('#myModal').modal('show');
        });

        $(document).ready(function () {
            $('#myModal').on('hidden.bs.modal', function () {
                window.location.href = "@(Url.RouteUrl("Login"))";
            })
        });
    </script>
}


